//package servlet;
//
//
//import util.EmailSender;
//
//
//import javax.mail.MessagingException;
//import javax.mail.internet.AddressException;
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.Cookie;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
////发送邮件服务器
//@WebServlet(name="SendEmailServlet",urlPatterns = "/SendEmailServlet")
//public class SendEmailServlet extends HttpServlet {
//    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        doGet(request,response);
//    }
//
//    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        sendSecurityCode(request,response);
//    }
//    private void sendSecurityCode(HttpServletRequest request, HttpServletResponse response) {
//        String qqEmail=request.getParameter("qqEmail");//获取qq邮箱
//        String securityCode= EmailSender.getSecurityCode(6);//随机生成6位数验证码
//        try {
//            Cookie emailCodeCookie = new Cookie("code", securityCode);
//            emailCodeCookie.setMaxAge(10*60);//设置cookie为十分钟
//            EmailSender.sendEmail(qqEmail, "您本次的验证码为：" + securityCode + ",十分钟内输入有效。若非本人操作，请忽略");
//            response.addCookie(emailCodeCookie);
//            System.out.println("已发送");
//        }catch (AddressException e) {
//            e.printStackTrace();
//        } catch (MessagingException e) {
//            e.printStackTrace();
//        }
//
//    }
//}
